//
//  MainViewController.m
//  TrunkIndustryManageSystem
//
//  Created by 李璐西 on 15-3-26.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "MainViewController.h"
#import "BiNetEngine.h"


@interface MainViewController ()<UIScrollViewDelegate, BiNetEngineDelegate>

@end

@implementation MainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    
    // 模拟请求
    [[BiNetEngine shareInstance] requestCarSaleCheckList:self index:0];
    
    _naviBarView = [[BiNaviBarView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
    [self.view addSubview:_naviBarView];
    [_naviBarView setHidden:NO];
    [_naviBarView setTitle:@"客户信息审批"];
    
//    [self setBackgroundColor:UIColorFromRGB(0x1ca0ff)];
    CGRect frame = [self.view bounds];
    UIScrollView *background = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, 320, frame.size.height)];
    [self.view addSubview:background];
    background.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:242.0/255.0 blue:247.0/255.0 alpha:100];
//    滚动
    background.contentSize = CGSizeMake(320, frame.size.height+100);
    background.delegate = self;
#pragma mark view1
//   background1*********************************************************
//    lables and image
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 22, 200, 35)];
    label.text = @"姓名，路人乙";
    label.font = [UIFont systemFontOfSize:15];
    [background addSubview:label];
    
//    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(140, 140, 150, 150)];
//    imageView.backgroundColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:1];
//    [self.view addSubview:imageView];
//    imageView.image = [UIImage imageNamed:@"tel@2x_03.png"];
//    [background addSubview:imageView];
//    imageView.hidden = NO;
//    NSLog(@"string is :%@self.view.subviews.count", string);
    
    UIButton *Button = [[UIButton alloc] initWithFrame:CGRectMake(170, 60, 40, 40)];
    [Button setImage:[UIImage imageNamed:@"tel@2x_03.png"] forState:UIControlStateNormal];
    [Button setTitle:@"" forState:UIControlStateNormal];
//    imageView = [UIImage imageNamed:@"tel@2x_03.png"];
//    [Button setTitle:@"清除文字" forState:UIControlStateNormal];
    [Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [Button addTarget:self action:@selector(onTextViewButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:Button];
    
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(110, 22, 200, 35)];
    label2.text = @"138-4832-9999";
    label2.font = [UIFont systemFontOfSize:15];
    [label2 setTextAlignment:NSTextAlignmentRight];
    [background addSubview:label2];

//    view1*********************************************************
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 60, 320, 115)];
    view1.backgroundColor = [UIColor whiteColor];
    [background addSubview:view1];
//row1
    UILabel *lablev11 = [[UILabel alloc] initWithFrame:CGRectMake(10, -5, 320, 44)];
    lablev11.text = @"身份证:5104022000123212301";
    lablev11.font = [UIFont systemFontOfSize:13];
    [view1 addSubview:lablev11];
//row2
    UILabel *lablev12 = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 320, 44)];
    lablev12.text = @"地址:四川省流水市客观龙大道22-25";
    lablev12.font = [UIFont systemFontOfSize:12];
    [view1 addSubview:lablev12];
//row3
    UILabel *lablev15 = [[UILabel alloc] initWithFrame:CGRectMake(10, 15+20, 320, 44)];
    lablev15.text = @"信息来源:城北城北城北派出所";
    lablev15.font = [UIFont systemFontOfSize:12];
    lablev15.numberOfLines = 2;
    [view1 addSubview:lablev15];

//    view2*********************************************************
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 230, 320, 78)];
    view2.backgroundColor = [UIColor whiteColor];
    [background addSubview:view2];
    
//    lable
    NSString *string1 = @"身份证:";
    CGSize sz1 = [string1 sizeWithFont:[UIFont systemFontOfSize:12] constrainedToSize:CGSizeMake(100, 1000)];
    
    UILabel *lablev2_1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 39, sz1.width, 44)];
    lablev2_1.text = @"身份证:";
    lablev2_1.font = [UIFont systemFontOfSize:14];
    [view2 addSubview:lablev2_1];
    
    UILabel *lablev2_2 = [[UILabel alloc] initWithFrame:CGRectMake(10+sz1.width+10, 39, 320, 44)];
    lablev2_2.text = @"5104022000123212301";
    lablev2_2.font = [UIFont systemFontOfSize:14];
    [view2 addSubview:lablev2_2];
    
    ////多列 3列规则
    //    NSString *string1 = @"民";
    //    CGSize sz1 = [string1 sizeWithFont:[UIFont systemFontOfSize:12] constrainedToSize:CGSizeMake(100, 1000)];
    //
    //    UILabel *lablev13 = [[UILabel alloc] initWithFrame:CGRectMake(10, 15+25, 100, 44)];
    //    lablev13.text = @"从业年限:10年";
    //    lablev13.font = [UIFont systemFontOfSize:12];
    //    lablev13.textAlignment = UITextAlignmentCenter;
    //    lablev13.numberOfLines = 2;
    //    [view1 addSubview:lablev13];
    //    lablev13.frame = CGRectMake(10, 15+35, 100, sz1.height);

    
// ****************************************************
    if (isIOS7)
    {
        [_naviBarView setFrame:CGRectMake(0, 0, _naviBarView.frame.size.width, 64)];
    }
    else
    {
        [_naviBarView setFrame:CGRectMake(0, -20, _naviBarView.frame.size.width, 64)];
    }
    [_naviBarView release];
    
    self.view.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:242.0/255.0 blue:247.0/255.0 alpha:100];
}

- (void)onGetCarSaleCheckList:(id)array
{
    if ([array isKindOfClass:[NSArray class]])
    {
        // 处理网络数据
    }
}

#pragma mark -
#pragma mark BiNetEngineDelegate
- (void)onNetEngineResponse:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    NSLog(@"onNetEngineResponse");
    
    switch (tag)
    {
        case NET_GET_CAR_SALE_CHECK_LIST:
        {
            [self onGetCarSaleCheckList:entity];
        }
            break;
            
        default:
            break;
    }
}
- (void)onNetEngineResponseFail:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    NSLog(@"onNetEngineResponseFail");
}

#pragma mark -------------------
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    // any offset changes
    NSLog(@"%f",scrollView.contentOffset.y);//这里我们输出 scrollView的纵向 偏移量
}
// called on start of dragging (may require some time and or distance to move)
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDragging");
}
// called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSLog(@"scrollViewDidEndDragging willDecelerate");
}
// called on finger up as we are moving
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDecelerating");
}
// called when scroll view grinds to a halt
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSLog(@"scrollViewDidEndDecelerating");
}


- (void)onTextViewButtonClicked:(UIButton*)button
{

}

@end
